
const { createWebAPIRequest } = require('../../util/util')

module.exports = [
  {
    /**
    * @api {get} /music/resource/like [喜欢resource]
    * @apiGroup Music
    * @apiPermission none
    * @apiParam {Number} id
    */
    url: '/music/resource/like',
    method: 'get',
    request: (req, res) => {
      const cookie = req.get('Cookie') ? req.get('Cookie') : ''
      const data = {
        threadId: req.query.id,
        csrf_token: ''
      }
      const action = req.query.t === 1 ? 'like' : 'unlike'
      createWebAPIRequest(
        'music.163.com',
        `/weapi/resource/${action}`,
        'POST',
        data,
        cookie,
        musicReq => {
          res.send(musicReq)
        },
        err => res.status(500).send({err})
      )
    }
  }
]
